#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <cstdlib>
#include <iomanip>
#include <ios>
#include <iostream>
#include <istream>
#include <ranges>
#include <stdexcept>
#include <type_traits>
#include <utility>
#include <queue>

using int64 = std::int64_t;

template<class ...Args>
void input(Args&&...args){
    (std::cin>>...>>std::forward<Args>(args));
}

template<class T>
std::remove_cv_t<T> input(){
    std::remove_cv_t<T> t;
    std::cin>>t;
    return t;
}

template<class ...Args>
void print(Args&&...args){
    (std::cout<<...<<args);
}

struct Point{
    int64 x, y;
    // bool operator<(const Point &that)const{
    //     return (this->x + this->y) < (that.x + that.y);
    // }
    bool operator==(const Point &that)const{
        return this->x == that.x && this->y == that.y;
    }
};

using Vector2 = Point;
using Status = std::pair<Vector2, Point>;

const int64 max_n = 100 + 5;
int64 _map[max_n][max_n];
const int64 (&map)[max_n][max_n] = _map;
std::bitset<max_n> vis[max_n];
const std::array<std::array<int64, 2>, 4> dir{{
    {0, 1},
    {1, 0},
    {-1, 0},
    {0, -1}
}};

int main(){
    std::iostream::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
    std::cout<<std::fixed<<std::setprecision(3);

    const int64 n = input<decltype(n)>(), m = input<decltype(m)>();

    const auto inputPoint = []()->Point{
        Point ret;
        input(ret.x, ret.y);
        return ret;
    };
    const Point start = inputPoint(), end = inputPoint();

    std::ranges::for_each(std::ranges::views::iota(1, n+1), [&](const auto &i){
        std::ranges::for_each(std::ranges::views::iota(1,m+1), [&](const auto &j){
            input(_map[i][j]);
        });
    });

    const double ansScore = input<double>();

    std::queue<Status> q;
    q.emplace(Vector2{0, 0}, start);
    vis[start.x][start.y] = true;

    const Vector2 ansVec = [&]()->Vector2{
        while(!q.empty()){
            const auto top = q.front();
            q.pop();

            if(top.second == end){
                return top.first;
            }

            for (const auto i : dir) {
                const Point nextPoint = {top.second.x + i[0], top.second.y + i[1]};
                if(map[nextPoint.x][nextPoint.y] == 1 || nextPoint.x < 1 || nextPoint.x > n 
                    || nextPoint.y < 1 || nextPoint.y > m
                    || vis[nextPoint.x][nextPoint.y]
                ){
                    continue;
                }
                vis[nextPoint.x][nextPoint.y] = true;
                q.emplace(Vector2{.x = top.first.x + std::abs(i[0]), .y = top.first.y + std::abs(i[1])}, nextPoint);
            }
        }
        throw std::runtime_error("unreachable");
    }();

    const double udTimes = ansScore - (double)ansVec.y;
    print(udTimes/ansVec.x);
}